<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
  <button>AJAX请求</button>
  <script>
    const btn = document.querySelector('button')
    btn.onclick = function () {
      fetch('http://127.0.0.1:8000/fetch-server?vip=10',{
        //请求方法
        method:'POST',
        //请求头
        headers:{
          name:'xionxiong',
        },
        //请求体
        body:'username=admin&password=admin'
      }).then(response=>{ //用then的回调函数来处理结果
        // return response.text() //返回字符串
        return response.json()//返回的是json 自动转换,返回对象
      }).then(response=>{
        console.log(response)
      })
    }


  </script>

</body>
</html>
